package com.zimmor.mq.rocket_train1.batch;


import com.zimmor.mq.RocketMQProperties;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

import java.util.*;

/**
 * @Author:zimmor
 * @Date: 2023/2/16 15:00
 * @Description
 * @version: 1.0.0
 */

public class Producer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer-group2");
        producer.setNamesrvAddr(RocketMQProperties.NAME_SRV_ADDR);
        producer.start();
        List<Message> list = new ArrayList<>();
        list.add(new Message("batch", "tag1", "batchMessage1".getBytes()));
        list.add(new Message("batch", "tag1", "batchMessage2".getBytes()));
        list.add(new Message("batch", "tag1", "batchMessage3".getBytes()));
        SendResult sendResult = producer.send(list);
        System.out.println("msg:" + sendResult);
        producer.shutdown();

    }
}
